const commonUrl = 'http://localhost:8080'
import axios from "axios";
import Qs from "qs";
const baseUrl = {
  commonUrl
}

export const userLogin = (user_name, user_password) => {
    return axios.post(
        commonUrl + '/sqlTest/login.do',
        Qs.stringify({ user_name:user_name, user_password:user_password })
    );
};

export const register = (user_name, user_password, user_sex, user_age, user_pro, user_hobby) => {

  return axios.post(commonUrl+"/sqlTest/register.do", Qs.stringify({
    user_name:user_name,
    user_password:user_password,
    user_sex:user_sex,
    user_age:user_age,
    user_pro:user_pro,
    user_hobby:user_hobby
  }))

};

export const getAllArticle = (page) => {
    return axios.post(commonUrl +"/sqlTest/showThemeAll.do", Qs.stringify({ page }));
};

export const getPersonbyId = (user_id) => {
    return axios.post(
        commonUrl + '/sqlTest/personMsg.do',
        Qs.stringify({ user_id:user_id})
    );
};


export const searchPersonbyName = (user_name) => {
    return axios.post(
        commonUrl + '/sqlTest/searchPerson.do',
        Qs.stringify({ user_name:user_name})
    );
};

export const searchThemebyTitle = (theme_post_title) => {
    return axios.post(
        commonUrl + '/sqlTest/searchTheme.do',
        Qs.stringify({ theme_post_title:theme_post_title})
    );
};



export const searchThemebyId = (theme_post_id) => {
    return axios.post(
        commonUrl + '/sqlTest/themeMsg.do',
        Qs.stringify({ theme_post_id:theme_post_id})
    );
};

export const searchReplybyId = (theme_post_id) => {
    return axios.post(
        commonUrl + '/sqlTest/showReplyAllByTheme.do',
        Qs.stringify({ theme_post_id:theme_post_id})
    );
};

export const searchFllowingByUserId = (user_id) => {
    return axios.post(
        commonUrl + '/sqlTest/showFollowList.do',
        Qs.stringify({ user_id:user_id})
    );
};

export const searchFanByUserId = (user_id) => {
    return axios.post(
        commonUrl + '/sqlTest/showFanList.do',
        Qs.stringify({ user_id:user_id})
    );
};



export const searchCollectionByUserId = (user_id) => {
    return axios.post(
        commonUrl + '/sqlTest/showThemeCollected.do',
        Qs.stringify({ user_id:user_id})
    );
};

export const searchThemeByUserId = (user_id) => {
    return axios.post(
        commonUrl + '/sqlTest/showThemeAllByUser_id.do',
        Qs.stringify({ user_id:user_id})
    );
};


export const searchReplyByUserId = (user_id) => {
    return axios.post(
        commonUrl + '/sqlTest/showReplyAllByUser_id.do',
        Qs.stringify({ user_id:user_id})
    );
};

export const updateUserMsg = (user_id,user_name, user_password, user_sex, user_age, user_pro, user_hobby) => {

  return axios.post(commonUrl+"/sqlTest/updateUserMsg.do", Qs.stringify({
    user_id:user_id,
    user_name: user_name,
    user_password:user_password,
    user_sex:user_sex,
    user_age:user_age,
    user_pro:user_pro,
    user_hobby:user_hobby
  }))

};


export const addNewReply = (theme_post_id,user_id,reply_post_content) => {
    return axios.post(
        commonUrl + '/sqlTest/addNewReply.do',
        Qs.stringify({
            theme_post_id: theme_post_id,
            user_id: user_id,
            reply_post_content:reply_post_content
        })
    );
};


export const showThemeAllByLock = () => {
    return axios.post(
        commonUrl + '/sqlTest/showThemeAllByLock.do',
        Qs.stringify({ })
    );
};

export const showPersonAllByLock = () => {
    return axios.post(
        commonUrl + '/sqlTest/showPersonAllByLock.do',
        Qs.stringify({ })
    );
};



export const unlockTheme = (theme_post_id) => {
    return axios.post(
        commonUrl + '/sqlTest/unlockTheme.do',
        Qs.stringify({theme_post_id:theme_post_id })
    );
};


export const unlockPerson = (user_id) => {
    return axios.post(
        commonUrl + '/sqlTest/unlockPerson.do',
        Qs.stringify({user_id:user_id })
    );
};


export const addNewTheme = (theme_post_title,theme_post_content,user_id) => {
    return axios.post(
        commonUrl + '/sqlTest/addNewTheme.do',
        Qs.stringify({
            theme_post_title: theme_post_title,
            theme_post_content:theme_post_content,
            user_id: user_id
        })
    );
};



export const deleteTheme = (theme_post_id) => {
    return axios.post(
        commonUrl + '/sqlTest/deleteTheme.do',
        Qs.stringify({
            theme_post_id: theme_post_id,
        })
    );
};


export const collectTheme = (user_id, theme_post_id) => {
    return axios.post(
        commonUrl + '/sqlTest/collectTheme.do',
        Qs.stringify({
            user_id:user_id,
            theme_post_id: theme_post_id
        })
    );
};

export const showThemeAllByFine = () => {
    return axios.post(
        commonUrl + '/sqlTest/showThemeAllByFine.do',
        Qs.stringify({ })
    );
};

export const followPerson = (user_id, follow_id) => {
    return axios.post(
        commonUrl + '/sqlTest/followPerson.do',
        Qs.stringify({user_id:user_id,follow_id:follow_id })
    );
};


export const lockTheme = (theme_post_id) => {
    return axios.post(
        commonUrl + '/sqlTest/lockTheme.do',
        Qs.stringify({theme_post_id:theme_post_id})
    );
};


export const lockPerson = (user_id) => {
    return axios.post(
        commonUrl + '/sqlTest/lockPerson.do',
        Qs.stringify({user_id:user_id})
    );
};

export default baseUrl
